<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use  common\models\Wxuser;
use kartik\datetime\DateTimePicker;
use  yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $searchModel common\models\search\WxuserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', '微信用户');
$this->params['breadcrumbs'][] = $this->title;
?>
<style>
    .table > thead > tr > th, .table > tbody > tr > th, .table > tfoot > tr > th, .table > thead > tr > td, .table > tbody > tr > td, .table > tfoot > tr > td {
         vertical-align: middle;
    }
    .table > thead > tr > th, .table > tbody > tr > th, .table > tfoot > tr > th{
        color: rgb(214,236,204);
    }
    .table-bordered>thead>tr>th, .table-bordered>tbody>tr>th, .table-bordered>tfoot>tr>th, .table-bordered>thead>tr>td, .table-bordered>tbody>tr>td, .table-bordered>tfoot>tr>td {
        border: 1px solid rgb(214,236,204);
    }
    .btn{
         border-radius:0px;!important;;
    }
    .btn-sm, .btn-group-sm > .btn{
        border-radius:0px;!important;;
    }
    .content {
        margin-right: 50px;
        margin-left: 50px;
        !important;
    }
</style>
<?php $form = ActiveForm::begin([
    'action' =>['/wxuser/index'],
    'method' => 'post'
]);?>
<div class="wxuser-index">
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'containerOptions'=>['style'=>'overflow: auto'], // only set when $responsive = false
        'headerRowOptions'=>['class'=>'kartik-sheet-style'],
        'filterRowOptions'=>['class'=>'kartik-sheet-style'],
        'columns' => [
            [
                'class' => '\kartik\grid\CheckboxColumn',
            ],
            [
                'class' => 'yii\grid\SerialColumn',
            ],
                [
                    'label'=>'微信头像',
                    'format'=>'raw',
                    'attribute' => 'wx_images',/*产生一个a标签,点击可排序*/
                    'contentOptions' => [ 'width' => '200px'],
                    'class'=>'kartik\grid\EditableColumn',
                    'value'=>function($m){
                    return Html::img($m->wx_images,['alt' => '微信头像','width' => 80]);
                }],
//            'id',
//            'username',
            'unionid',
//            'openid',
            [
                'label'=>'微信名称',
                'format'=>'raw',
                'attribute' => 'wx_name',/*产生一个a标签,点击可排序*/
                'contentOptions' => ['style' => 'vertical-align: middle;', 'width' => '200px'],
                'class'=>'kartik\grid\EditableColumn',
                'value'=>function($m){
                    return $m->wx_name;
                }
            ],
                [
                    'attribute' => 'sex',
                    'class'=>'kartik\grid\EditableColumn',
                    'editableOptions'=>[
                        'inputType'=>\kartik\editable\Editable::INPUT_DROPDOWN_LIST,
                        'asPopover' => false,
                        'data' => Wxuser::SexAlias("all"),
                    ],
                    'value' => function ($model) {
                        return Wxuser::SexAlias($model->sex);
                    },
                    'filter' => Wxuser::SexAlias("all"),
                ],
            //日期组件
            [
                'attribute' => 'created_at',
                //这个设定表格的宽度
                // 'headerOptions' => ['width' => '150px'],
//                'class'=>'kartik\grid\EditableColumn',
//                'editableOptions'=>[
//                    'inputType'=>\kartik\editable\Editable::INPUT_DATE,
//                    'asPopover' => false,
//                    //这个设定我们组件的宽度
//                    'contentOptions' => ['style'=>'width:180px'],
//                    'options' => [
//                        'pluginOptions' => [
//                            //设定我们日期组件的格式
//                            'format' => 'yyyy-mm-dd',
//                        ]
//                    ],
//                ],
                'filter' => DateTimePicker::widget([
                    'language' => 'zh-CN',
                    'model' => $searchModel,
                    'type' => DateTimePicker::TYPE_COMPONENT_APPEND,
                    'attribute' => 'created_at',
                    'options' => ['class' => 'input-sm'],
                    'pluginOptions' => [
                        'autoclose' => true,
                        'format' => 'yyyy-mm-dd hh:ii:ss',
                        'minView' => 'month',
                    ]]),
                'value'=>function($model){
                    return  date('Y-m-d H:i:s',$model->created_at);   //主要通过此种方式实现
                },
            ],

            //时间组件
            [
                'attribute' => 'updated_at',
//                 'headerOptions' => ['width' => '150px'],
//                'class'=>'kartik\grid\EditableColumn',
//                'editableOptions'=>[
//                    'inputType'=>\kartik\editable\Editable::INPUT_DATETIME,
//                    'asPopover' => false,
//                    'contentOptions' => ['style'=>'width:250px'],
//                ],

                'filter' => DateTimePicker::widget([
                    'language' => 'zh-CN',
                    'model' => $searchModel,
                    'type' => DateTimePicker::TYPE_COMPONENT_APPEND,
                    'attribute' => 'updated_at',
                    'options' => ['class' => 'input-sm'],
                    'pluginOptions' => [
                        'format' => 'datetime',
                        'autoclose' => true,
                        'minView' => 'month',
                    ]]),
                'value'=>function($model){
                    return  date('Y-m-d H:i:s',$model->updated_at);   //主要通过此种方式实现
                },
            ],
            [
                'class' => 'kartik\grid\ActionColumn',
                'headerOptions' => ['class' => 'kartik-sheet-style'],
            ],
        ],
        'export' => false,
        'responsive' => true,
        'panel' => [
                'heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-globe"></i> ' .Yii::t('Wxuser','用户'). '</h3>',
                'type' => 'success',
                'before' => Html::a('<i class="glyphicon glyphicon-plus"></i>' . Yii::t('Wxuser','创建用户'), ['create'], ['class' => 'btn btn-success']),
            'footer' => false,
            'after' => false
        ],
        'toolbar' => [
            [
                'content' =>
                    Html::dropDownList('act', '',
                        [
                            '' => Yii::t('Wxuser','选择操作') ,
                            'delete' =>  Yii::t('Wxuser','删除') ,

                        ],
                        ['class' => 'btn btn-default', 'style' => 'margin-right:10px']) . Html::submitButton( Yii::t('Wxuser','保存'), ['class' => 'btn btn-success']),
                        'options' => ['class' => 'btn-group-sm'],
                            '{export}',
                    '{toggleData}'
            ],
            'toggleDataContainer' => ['class' => 'btn-group-sm'],
            'exportContainer' => ['class' => 'btn-group-sm']
        ],
    ]); ?>
<?php ActiveForm::end(); ?>
